package SocketTool;



import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketException;

class SendNews {
	private String ip = "";
	private int port = 0;
	DatagramPacket dp = null;
	DatagramSocket ds = null;

	SendNews() {
		this.ip = "192.168.1.105";
		this.port = 8900;
	}

	public static SendNews getInstance() {
		return new SendNews();
	}

	public void init() {
		try {
			ds = new DatagramSocket(this.port);
		} catch (SocketException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void Send(String str) {
		InetSocketAddress isa = new InetSocketAddress("192.168.1.105", 5800);

		try {
			dp = new DatagramPacket(str.getBytes(), 0, str.getBytes().length,
					isa);
		} catch (SocketException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			ds.send(dp);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}